[xen] Update the hvm rtc clock state if the domain's time offset is changed.
authorChristian Limpach <Christian.Limpach@xensource.com>
Thu, 8 Mar 2007 15:51:32 +0000 (15:51 +0000)
committerChristian Limpach <Christian.Limpach@xensource.com>
Thu, 8 Mar 2007 15:51:32 +0000 (15:51 +0000)
The settimeoffset domctl had no effect on hvm domains since the offset
was only read in rtc_init which is done when the domain is created.

Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
xen/arch/x86/hvm/rtc.c
xen/include/asm-x86/hvm/vpt.h

index 5cda6bbb7564d0c8f4933ce28f07ccd480dbcc79..036eba7bfecbfecf9e51f03d62bc57294c09e1ae 100644 (file)
@@ -174,6 +174,11 @@ static void rtc_copy_date(RTCState *s)
 {
     const struct tm *tm = &s->current_tm;
 
+    if (s->time_offset_seconds != s->pt.vcpu->domain->time_offset_seconds) {
+        s->current_tm = gmtime(get_localtime(s->pt.vcpu->domain));
+        s->time_offset_seconds = s->pt.vcpu->domain->time_offset_seconds;
+    }
+
     s->hw.cmos_data[RTC_SECONDS] = to_bcd(s, tm->tm_sec);
     s->hw.cmos_data[RTC_MINUTES] = to_bcd(s, tm->tm_min);
     if ( s->hw.cmos_data[RTC_REG_B] & RTC_24H )
@@ -211,10 +216,16 @@ static int get_days_in_month(int month, int year)
 }
 
 /* update 'tm' to the next second */
-static void rtc_next_second(struct tm *tm)
+static void rtc_next_second(RTCState *s)
 {
+    struct tm *tm = &s->current_tm;
     int days_in_month;
 
+    if (s->time_offset_seconds != s->pt.vcpu->domain->time_offset_seconds) {
+        s->current_tm = gmtime(get_localtime(s->pt.vcpu->domain));
+        s->time_offset_seconds = s->pt.vcpu->domain->time_offset_seconds;
+    }
+
     tm->tm_sec++;
     if ((unsigned)tm->tm_sec >= 60) {
         tm->tm_sec = 0;
@@ -258,7 +269,7 @@ static void rtc_update_second(void *opaque)
     }
     else
     {
-        rtc_next_second(&s->current_tm);
+        rtc_next_second(s);
         
         if ( !(s->hw.cmos_data[RTC_REG_B] & RTC_SET) )
             s->hw.cmos_data[RTC_REG_A] |= RTC_UIP;
index 02bc3fa05c7313a6ea2ffdcace8a420abe08c6f3..bda54adfc37e4c6b53851f9ee7e920f40fe1f72c 100644 (file)
@@ -92,6 +92,7 @@ typedef struct RTCState {
     struct timer second_timer;
     struct timer second_timer2;
     struct periodic_time pt;
+    int32_t time_offset_seconds;
 } RTCState;
 
 #define FREQUENCE_PMTIMER  3579545  /* Timer should run at 3.579545 MHz */